/**
 * Development-mode only bootstrap
 */

import org.codehaus.groovy.grails.commons.ApplicationHolder
import org.codehaus.groovy.grails.web.context.ServletContextHolder
 
import org.weceem.event.Events

 
class BootStrap {
	
    def initialised = true
    
    def init = { servletContext ->
        def ctx = ApplicationHolder.application.mainContext
		
        def wcmEventService = ctx.wcmEventService
        def contentEventListenerService = ctx.contentEventListenerService
        wcmEventService.registerListener(Events.AFTER_CONTENT_ADDED, contentEventListenerService)
        wcmEventService.registerListener(Events.AFTER_CONTENT_REMOVED, contentEventListenerService)
        wcmEventService.registerListener(Events.AFTER_CONTENT_UPDATED, contentEventListenerService)
		
        def contentFileBinService = ctx.contentFileBinService
        if (!initialised) {
            contentFileBinService.initialize()
        }
		
        contentFileBinService.restoreAll()
    }
    
    def destroy = {
        
    }
}